Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EHR sql server error #5123

Merged
merged 4 commits into from
Jan 15, 2024
Merged

Fix EHR sql server error #5123

merged 4 commits into from
Jan 15, 2024

Conversation

XingY
Copy link
Contributor

@XingY XingY commented Jan 12, 2024

Rationale

#5089 introduced a change to use the same transaction in a nested way. This turns out to be causing issues for sql server, see related failures

This PR reverts the !transacted change to use NO_OP transaction for the inner transaction, and seek to handle transaction audit on an alternative current transaction.
Good run

Related Pull Requests

Changes

@XingY XingY requested review from a team and labkey-susanh January 12, 2024 16:37
@@ -4976,7 +4980,7 @@ else if (scope != tableInfo.getSchema().getScope())
}
commandObject.put("extraContext", commandExtraContext);

JSONObject commandResponse = executeJson(commandObject, command, transacted, errors);
JSONObject commandResponse = executeJson(commandObject, command, !transacted, errors);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't quite get why this got switched to !transacted. This says if it's not transacted we'll allow transaction if the JSON property is true, but if it is transacted here and that property is true, we don't allow transactions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been like this for 12 years. I think it got flipped because it was trying to avoid nested transaction and have the outer transaction used only. Attempt to reverse is resulted in sql server transaction already rolled back error.

auditEvent = transaction.getAuditEvent();
DbScope.Transaction auditTransaction = transacted ? transaction : table.getSchema().getScope().getCurrentTransaction();
if (auditTransaction == null)
auditTransaction = transaction;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this. If transacted is true, we use the ensured transaction from the try block and if it's false we get the transaction from the table schema. Presumably if it's transacted, these are the same thing. If there is no transaction on the table schema, we use the NO_OP_TRANSACTION. So could this be
`

Suggested change
auditTransaction = transaction;
DbScope.Transaction auditTransaction = table.getSchema().getScope().getCurrentTransaction();
if (auditTransaction == null)
auditTransaction = NO_OP_TRANSACTION;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've modified the logic a little bit more to only get scope transaction when the outer caller is indeed transacted.

Copy link
Contributor

@labkey-susanh labkey-susanh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. That's a bit more understandable

@XingY XingY merged commit a1c81eb into develop Jan 15, 2024
12 of 13 checks passed
@XingY XingY deleted the fb_fixTransacted branch January 15, 2024 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants